//
//  RequesetManager.h
//  片刻
//
//  Created by lanou3g on 15/6/4.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import <Foundation/Foundation.h>
//定义枚举，枚举请求的类型
typedef NS_ENUM(NSInteger, RequestModel) {
    POST,
    GET
};

@protocol RequestDelegate <NSObject>

//请求完毕后让代理对象执行的方法，同时吧请求完整的data传给代理对象
-(void)requestDidFinshWithData:(NSData *)data;
//请求失败后把错误的原因传值给代理对象
-(void)requestError:(NSError *)error;

@end

@interface RequesetManager : NSObject <NSURLConnectionDataDelegate>
@property (nonatomic,copy) NSString *requestURL; //请求网址
@property (nonatomic,copy) NSString *requesParameyer; //请求参数
@property (nonatomic,assign) RequestModel requestModel;//请求类型
@property (nonatomic,retain) NSMutableData *data; //接受返回的data
@property (nonatomic,retain) NSMutableDictionary *parameyerDict;//字典参数
@property (nonatomic,assign) id<RequestDelegate> delegate; //保存代理对象
//初始化方法
-(instancetype)initWithRequestURL:(NSString *)urlString requestModel:(RequestModel)requstModel parameyer:(NSString *)parameyer;
//开启请求
-(void)startRequest;
@end
